<?php

namespace app\admin\model\chase;

use app\admin\model\Admin;
use think\Model;
use traits\model\SoftDelete;

class Trend extends Model
{

    use SoftDelete;

    

    // 表名
    protected $table = 'trends';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = 'deletetime';

    // 追加属性
    protected $append = [
        'is_show_text'
    ];
    

    
    public function getIsShowList()
    {
        return ['no' => __('Is_show no'), 'yes' => __('Is_show yes')];
    }


    public function getIsShowTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_show']) ? $data['is_show'] : '');
        $list = $this->getIsShowList();
        return isset($list[$value]) ? $list[$value] : '';
    }

    public function admin()
    {
        return $this->hasOne(Admin::class, 'id', 'admin_id');
    }



}
